import { ApiProperty } from "@nestjs/swagger";
import { IsIn, IsNotEmpty, IsOptional, IsString, MinLength } from "class-validator";

export class SysUserLoginDto {
    @IsString()
    @IsNotEmpty({ message: "用户名不能为空" })
    @ApiProperty({
        description: "用户名",
        example: "JohnDoe",
        required: true
    })
    username: string;

    @IsString()
    @IsNotEmpty({ message: "密码不能为空" })
    @MinLength(6, { message: "密码至少6个字符" })
    @ApiProperty({
        description: "密码",
        example: "password123",
        required: true
    })
    password: string;

    // @Transform(({ value }) => Number(value))
    @IsString()
    @IsNotEmpty({ message: "登录终端不能为空" })
    @IsIn(["pc", "mobile"], { message: "登录终端只能为pc或mobile" })
    @ApiProperty({
        description: "登录终端,1-pc管理后台;2-手机管理后台",
        example: "pc",
        required: true
    })
    terminal: string;

    @IsString()
    @IsOptional()
    @ApiProperty({
        description: "验证码",
        example: "ikun",
        required: false
    })
    captcha?: string;
}
